package com.cskaoyan.service.wxservice.impl;

import com.cskaoyan.bean.po.MarketFootprint;
import com.cskaoyan.bean.po.MarketFootprintExample;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.mapper.MarketFootprintMapper;
import com.cskaoyan.service.wxservice.FootprintWxService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author:J
 * @datetime 2023/1/2 7:09
 * @description: TODO:footprint list ,delete
 */
@Service
public class FootprintWxServiceImpl implements FootprintWxService {

    @Autowired
    MarketFootprintMapper marketFootprintMapper;


    /**
     * footprint表里内容和显示内容对不上。
     * @param info
     * @return
     */
    @Override
    public CommonData<MarketFootprint> list(BasePageInfo info) {
        //分页
        PageHelper.startPage(info.getPage(),info.getLimit());
        //
        MarketFootprintExample example=new MarketFootprintExample();
        MarketFootprintExample.Criteria criteria= example.createCriteria();
        //查询deleted非1的footprint
        criteria.andDeletedEqualTo(false);

        List<MarketFootprint> marketFootprintList=
                marketFootprintMapper.selectByExample(example);

        PageInfo pageInfo=new PageInfo<>(marketFootprintList);

        return CommonData.data(pageInfo);
    }

    /**
     * 找不到删除位置。
     * @param marketFootprint
     */
    @Override
    public void delete(MarketFootprint marketFootprint) {
        marketFootprint.setDeleted(true);
        marketFootprintMapper.updateByPrimaryKeySelective(marketFootprint);
    }

}
